<?php
require_once(OC_App::getAppPath('resumes') . "/lib/helper.php");
$LoginStats = PUtil::checkUserLogin(true);
if ($LoginStats !== true) {
   echo $LoginStats;
   exit;
}
OCP\JSON::callCheck();
$user=PFactory::getUser();
$attachname=JRequest::getString('attachname');
if(empty($attachname))
   exit;
$attachment=basename($attachname);
$session=PFactory::getSession();
if(!preg_match("/^".$session->getId()."/", $attachment))
   exit;
$datadir = getUserDataDir($user->id);
$extdir = getUserExtDir($user->id); 
$upload_path=OC::$SERVERROOT.'/data'.$datadir.'/company/'.$extdir.'/resumes/upload';
if(JFile::exists($upload_path.'/'.$attachname)){
   JFile::delete($upload_path.'/'.$attachname);
}
OCP\JSON::success();
